use mf_core::{extension::Extension, types::Extensions};
use mf_state::plugin::{Plugin, PluginSpec};
use std::sync::Arc;

pub mod command;
pub mod nodes;
pub mod plugins;


pub use nodes::node_definitions::{CsxmNode, DeNode, DeRcjNode, FbNode, FbfxNode, QdNode};
use crate::plugins::csxm_plugins::plugin_csxm;
use crate::plugins::fbfx_plugins::plugin_fbfx;

/// 分部分项和措施项目工厂
pub struct FbfxCsxmFactory;

impl FbfxCsxmFactory {
    pub fn build() -> Vec<Extensions> {
        let mut extensions = Vec::new();
        let nodes = FbfxCsxmFactory::create_complete_structure();
        for d in nodes {
            extensions.push(Extensions::N(d));
        }
        let mut base_schema_ext = Extension::new();
        base_schema_ext
            .add_plugin(plugin_csxm::new().into())
            .add_plugin(plugin_fbfx::new().into());
        extensions.push(Extensions::E(base_schema_ext));
        extensions
    }

    /// 创建分部分项节点结构
    pub fn create_fbfx_structure() -> Vec<mf_core::node::Node> {
        let fbfx = FbfxNode::node_definition();
        let fb = FbNode::node_definition();
        let qd = QdNode::node_definition();
        let de = DeNode::node_definition();
        let de_rcj = DeRcjNode::node_definition();

        vec![fbfx, fb, qd, de, de_rcj]
    }

    /// 创建措施项目节点结构
    pub fn create_csxm_structure() -> Vec<mf_core::node::Node> {
        let csxm = CsxmNode::node_definition();
        let fb = FbNode::node_definition();
        let qd = QdNode::node_definition();
        let de = DeNode::node_definition();
        let de_rcj = DeRcjNode::node_definition();

        vec![csxm, fb, qd, de, de_rcj]
    }

    /// 创建完整的分部分项和措施项目结构
    pub fn create_complete_structure() -> Vec<mf_core::node::Node> {
        let mut nodes = Self::create_fbfx_structure();
        nodes.extend(Self::create_csxm_structure());
        nodes
    }
}
